﻿using System;
using Jayden.Dll.Web.HtmlControls;

namespace Jayden.Dll.Web.Controls
{
	public class CopyrightFooter : Footer
	{
		private A m_Website;
		private A m_Author;
		private Span m_Year;
		private Span m_Product;

		public override void Load(System.Xml.XmlNode node, HtmlControlLoader loader)
		{
			base.Load(node, loader);

			m_Website = GetElementByServerId<A>("website");
			m_Author = GetElementByServerId<A>("author");
			m_Year = GetElementByServerId<Span>("year");
			m_Product = GetElementByServerId<Span>("product");

			m_Year.InnerText = DateTime.Now.Year.ToString();
		}

		public override void ProcessHtmlRequest(HttpHandlerContext context)
		{
			m_Website.HRef = context.Configuration.GetValue("Website/@url", m_Website.HRef);
			m_Website.InnerText = context.Configuration.GetValue("Website/@name", m_Website.InnerText);
			m_Author.HRef = context.Configuration.GetValue("Website/Author/@url", m_Author.HRef);
			m_Author.InnerText = context.Configuration.GetValue("Website/Author/@name", m_Author.InnerText);
			m_Product.InnerText = context.Configuration.GetValue("Website/Product/@name", m_Product.InnerText);

			base.ProcessHtmlRequest(context);
		}
	}
}
